package innerclass;/**
 * Description
 * <p>
 * </p>
 * DATE 2019/12/1.
 *
 * @author cuihao.
 */

import java.util.ArrayList;
import java.util.List;

/**
 * 成员内部类
 *
 * @program: ch-general
 * @description:
 * @author: cuihao
 * @create: 2019-12-01 22:04
 **/
public class Outer {

    private static String s2;
    public List<String> list = new ArrayList<String>() {
        {
            add("test");
        }
    };
    private String s1;

    public static void main(String[] args) {
        // 创建成员内部类
        InnerA innerA = new Outer().new InnerA();

        // 创建静态成员内部类
        StaticInnerA staticInnerA = new Outer.StaticInnerA();

        // 创建局部内部类
        Outer outer = new Outer();
        outer.test();

        // 匿名内部类

        //
        System.out.println("executed");
    }

    public void test() {
        String s3 = "innerC";
        class InnerC {
            {
                System.out.println(s1);
                System.out.println("innerC");
            }
        }
    }

    public static class StaticInnerA {
        static String a = s2;
        String b = s2;
    }

    public class InnerA {
        String a = s1;
        String b = Outer.this.s1;
    }
}

